package com.ctg.itrdc.sysmgr.portal.control;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ctg.itrdc.pasp.security.SecUser;
import com.ctg.itrdc.pasp.security.utils.WebUtils;
import com.ctg.itrdc.sysmgr.portal.utils.CookieUtils;

@Controller
@RequestMapping("/sysLogin")
public class SysLoginController extends SysmgrBaseController{

//	private static final String SPRING_PROFILES_PREF = "spring.profiles.";
//	public static final String SPRING_PROFILES_ACTIVE = SPRING_PROFILES_PREF
//			+ "active";
//	public static final String SPRING_PROFILES_DEFAULT = SPRING_PROFILES_PREF
//			+ "default";
	
	@RequestMapping
	public String login(HttpServletRequest request,HttpServletResponse response){
//		String activeStr = System.getProperty(SPRING_PROFILES_ACTIVE);
//		activeStr = StringUtils.isNotBlank(activeStr) ? activeStr : request
//				.getServletContext().getInitParameter(SPRING_PROFILES_ACTIVE);
//		if (StringUtils.isBlank(activeStr)) {
//			String defaultStr = System.getProperty(SPRING_PROFILES_DEFAULT);
//			activeStr = StringUtils.isNotBlank(defaultStr) ? defaultStr
//					: request.getServletContext().getInitParameter(
//							SPRING_PROFILES_DEFAULT);
//		}
		SecUser ctgUser = WebUtils.getCtgUser();
		if(ctgUser!=null){
			CookieUtils.setCookie(response, "ctgUser", ctgUser);
		}
		return redirect+"/console/dist/#/login";
	}
}
